local jiumeng_qigong = fk.CreateSkill {

  name = "jiumeng_qigong",

  tags = {  },

}



jiumeng_qigong:addEffect(fk.CardUsing, {
  name = "jiumeng_qigong",
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(jiumeng_qigong.name) and target and target == player and player.phase == Player.Play and player:usedSkillTimes(jiumeng_qigong.name) == 0 and data.card and data.card.trueName == "slash"
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player,{ skill_name = jiumeng_qigong.name, prompt= "#jiumeng_qigong_evoke"})
  end,
  on_use = function (self, event, target, player, data)
    data.additionalDamage = (data.additionalDamage or 0) * 3 + 2
    data.card.skillName = jiumeng_qigong.name
  end,
})
jiumeng_qigong:addEffect(fk.CardUseFinished, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(jiumeng_qigong.name) and target and target == player and data.card and data.card.skillName == jiumeng_qigong.name
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    local isResponse = false
    local use_events = room.logic.event_recorder[GameEvent.UseCard] or Util.DummyTable
    local cards = data.cardsResponded
    if cards ~= nil then
      for i = #use_events, 1, -1 do
        local e = use_events[i]
        local use = e.data[1]
        if e.data[1] == data then break end
        --FIXME:还需要更加精准的判断
        if table.contains(cards, use.card) then
          isResponse = true
        end
      end
    end
    if isResponse then
      room:recover{
        who = player,
        num = 1,
        skillName =jiumeng_qigong.name,
        recoverBy = player,
      }
      room:addPlayerMark(player,"@jiumeng_qi",1)
    end
  end,
})

return jiumeng_qigong